#ifndef DBWRAPPER_H
#define DBWRAPPER_H

#include "database/database.h"
#include "globals.h"

class AData;
class DataMidi;
class DataRoot;
class DataLocator;

template <class Data, class Index, class Type>
class Database;


class DBWrapper
{
public:
    DBWrapper();
    enum Type {ROOT, MIDI, LOCATOR};
  //  enum {N_LOCATORS = 10};
    typedef db::Database< AData, gl::TicksTime, Type > Db;
    typedef db::Record< AData, gl::TicksTime, Type > Rec;

    void add(DataLocator * data, gl::TicksTime time);
    void add(DataMidi * data, gl::TicksTime time);

    void remove(const AData & data);
    void move(const AData & data, gl::TicksTime time);

    Rec * root() const {return static_cast <Rec*> (dbase_->getRootId());}
    Rec * locator(int id);

    QMutex & mutex() const {return dbase_->mutex();}

    void dump(Rec * r) const;

private:
    void add_specialized(AData * data, gl::TicksTime time,
                         const AData * parent, Type type);
    Db * dbase_;

};



#endif // DBWRAPPER_H
